package es.udc.iagolast.androidJam.Util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Night {
	private final SimpleDateFormat dateFormat = new SimpleDateFormat(
			"yyyy/MMM/d");
	private Date date;
	private List<MyMarker> markerList;

	public Night(String input) {
		super();

		String[] splitInput = input.split("@");
		Date dateToSet;
		try {
			dateToSet = dateFormat.parse(splitInput[0]);
			this.setDate(dateToSet);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		String[] dataList = input.split("_");

		for (String s : dataList) {
			MyMarker marker = new MyMarker(s);
			markerList.add(marker);
		}

	}

	public Night() {
		super();
		this.date = new Date();
		markerList = new ArrayList<MyMarker>();
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public List<MyMarker> getMarkerList() {
		return markerList;
	}

	public void setMarkerList(List<MyMarker> markerList) {
		this.markerList = markerList;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder(dateFormat.format(this.date));

		for (MyMarker marker : this.markerList) {
			builder.append(marker.toString() + "_");
		}
		return builder.toString();

	}
}
